var UPDATER={version:1.24};
var UpdaterDOMUtils={};
UpdaterDOMUtils.ELEMENT_NODE=1;
UpdaterDOMUtils.TEXT_NODE=3;
UpdaterDOMUtils.DOCUMENT_NODE=9;
UpdaterDOMUtils.getElement=function(_42f){
var _430=COMMONS.isString(_42f)?document.getElementById(_42f):_42f;
return _430;
};
UpdaterDOMUtils.getDocument=function(_431){
var _432=_431;
if(_431.nodeType!==this.DOCUMENT_NODE){
_432=_431.ownerDocument;
}
return _432;
};
UpdaterDOMUtils.addEventListener=function(_433,_434,_435){
var _436=this.getElement(_433);
if(_436){
if(COMMONS.isIE){
_436.attachEvent("on"+_434,_435);
}else{
_436.addEventListener(_434,_435,true);
}
}
};
UpdaterDOMUtils.removeEventListener=function(_437,_438,_439){
var _43a=this.getElement(_437);
if(_43a){
if(COMMONS.isIE){
_43a.detachEvent("on"+_438,_439);
}else{
_43a.removeEventListener(_438,_439,true);
}
}
};
UpdaterDOMUtils.getEventTarget=function(_43b){
var _43c=_43b.srcElement||_43b.target;
if(_43c&&_43c.nodeType===this.TEXT_NODE){
_43c=_43c.parentNode;
}
return _43c;
};
UpdaterDOMUtils.getEventKeyCode=function(_43d){
var _43e=_43d.keyCode||_43d.charCode;
return _43e;
};
function Executor(_43f,_440,_441,_442,_443){
this.fOnStop=_442;
this.fProcess=_43f;
this.fWait=_443;
this.fLock=false;
this.fCounter=isNaN(_441)?1000000:_441;
this.fTimeout=isNaN(_440)?500:_440;
this.fLockCheckerTimeout=Math.round(this.fTimeout()/4);
this.fOwnExecutor=null;
this.fJoinedExecutors=[];
this.fLogger=new Logger("Executor");
this.fTaskID=null;
this.fLockCheckerTaskID=null;
}
Executor.prototype.isLocked=function(){
var _444=this.fTaskID&&this.fLock;
if(!_444){
var _445;
for(var i=0;i<this.fJoinedExecutors.length;i++){
_445=this.fJoinedExecutors[i];
if(_445.isLocked()){
_444=true;
break;
}
}
}
return _444;
};
Executor.prototype.isAlive=function(){
return this.fCounter>0;
};
Executor.prototype.onStopCallBack=function(){
if(COMMONS.isFunction(this.fOnStop)){
try{
this.fOnStop.call(this);
}
catch(ex){
this.fLogger.error("Executor onStop error caused",ex);
}
}
};
Executor.prototype.start=function(){
this.fLock=false;
this.doStart();
};
Executor.prototype.doStart=function(){
var _447=this;
if(this.fLockCheckerTaskID!==null){
window.clearTimeout(this.fLockCheckerTaskID);
this.fLockCheckerTaskID=null;
}
if(this.isLocked()){
this.fLockCheckerTaskID=window.setTimeout(function(){
_447.doStart();
},this.fLockCheckerTimeout);
}else{
if(this.fTaskID!==null){
window.clearTimeout(this.fTaskID);
this.fTaskID=null;
}
if(this.isAlive()){
if(COMMONS.isFunction(this.fProcess)){
if(this.fWait){
this.fLock=true;
}
try{
this.fProcess.call(this);
}
catch(ex){
this.fLogger.error("Executor process error caused",ex);
}
this.fLock=false;
}
this.fCounter--;
this.fTaskID=window.setTimeout(function(){
_447.doStart();
},this.fTimeout);
}else{
this.onStopCallBack();
}
}
};
Executor.prototype.stop=function(){
this.fCounter=-1;
var _448;
for(var i=0;i<this.fJoinedExecutors.length;i++){
_448=this.fJoinedExecutors[i];
if(_448.isAlive()){
try{
_448.stop();
}
catch(ex){
this.fLogger.error("Unable to stop an executor because an error occured",ex);
}
}
}
};
Executor.prototype.fireStop=function(){
var _44a;
for(var i=0;i<this.fJoinedExecutors.length;i++){
_44a=this.fJoinedExecutors[i];
try{
_44a.fireStop();
}
catch(ex){
this.fLogger.error("Unable to stop an executor because an error occured",ex);
}
}
if(this.fLockCheckerTaskID!==null){
window.clearTimeout(this.fLockCheckerTaskID);
this.fLockCheckerTaskID=null;
}
if(this.fTaskID!==null){
window.clearTimeout(this.fTaskID);
this.fTaskID=null;
}
this.onStopCallBack();
this.fCounter=-1;
};
Executor.prototype.chain=function(_44c){
if(_44c instanceof Executor){
_44c.fOwnExecutor=this;
this.fJoinedExecutors.push(_44c);
}else{
this.fLogger.error("joinProcess, illegal argument type: "+_44c);
}
};
function Updater(_44d,_44e){
this.fActions=[];
this.fUIProcessors=new HashMap();
this.fKeys=new HashMap();
this.fKeyBuffer="";
this.fKeyBufferSize=-1;
this.fLock=false;
this.fCheckWord=false;
this.fCheckKey=false;
this.fProcessID=null;
this.fAutoRepeatTaskID=null;
this.fTimeout=isNaN(_44d)?50:_44d;
this.fLogger=new Logger("Updater");
this.fContainer=COMMONS.isObject(_44e)||document;
this.initKeyMaps();
this.initUIProcessors();
}
Updater.KB_BSP=8;
Updater.KB_TAB=9;
Updater.KB_CENTER=12;
Updater.KB_ENTER=13;
Updater.KB_CTRL=17;
Updater.KB_CAPS=20;
Updater.KB_ESC=27;
Updater.KB_PAGE_UP=33;
Updater.KB_PAGE_DOWN=34;
Updater.KB_END=35;
Updater.KB_HOME=36;
Updater.KB_LEFT=37;
Updater.KB_UP=38;
Updater.KB_RIGHT=39;
Updater.KB_DOWN=40;
Updater.KB_DEL=46;
Updater.KB_PLUS=107;
Updater.KB_MINUS=109;
Updater.KB_PLUS_KB=61;
Updater.KB_MINUS_KB=189;
Updater.prototype.registerKeyMap=function(_44f,_450){
this.fKeys.put(_44f,_450);
};
Updater.prototype.initKeyMaps=function(){
this.registerKeyMap("LEFT",Updater.KB_LEFT);
this.registerKeyMap("UP",Updater.KB_UP);
this.registerKeyMap("RIGHT",Updater.KB_RIGHT);
this.registerKeyMap("DOWN",Updater.KB_DOWN);
this.registerKeyMap("PAGE_UP",Updater.KB_PAGE_UP);
this.registerKeyMap("PAGE_DOWN",Updater.KB_PAGE_DOWN);
this.registerKeyMap("PLUS",Updater.KB_PLUS);
this.registerKeyMap("PLUSKB",Updater.KB_PLUS_KB);
this.registerKeyMap("MINUS",Updater.KB_MINUS);
this.registerKeyMap("MINUSKB",Updater.KB_MINUS_KB);
this.registerKeyMap("TAB",Updater.KB_TAB);
this.registerKeyMap("CENTER",Updater.KB_CENTER);
this.registerKeyMap("ENTER",Updater.KB_ENTER);
this.registerKeyMap("ESC",Updater.KB_ESC);
};
Updater.prototype.registerUIProcessor=function(_451,_452){
this.fUIProcessors.put(_451,_452);
};
Updater.prototype.initUIProcessors=function(){
this.registerUIProcessor("IMG",this.updateImageUI);
this.registerUIProcessor("BUTTON",this.updateControlUI);
this.registerUIProcessor("INPUT",this.updateControlUI);
this.registerUIProcessor("A",this.updateBlockUI);
this.registerUIProcessor("TD",this.updateBlockUI);
this.registerUIProcessor("DIV",this.updateBlockUI);
};
Updater.prototype.getUIProcessor=function(_453,_454){
var _455=undefined;
if(COMMONS.isObject(_453)&&_453.nodeType===UpdaterDOMUtils.ELEMENT_NODE){
_455=this.fUIProcessors.get(_453.nodeName);
}
return _455;
};
Updater.prototype.parseHotKey=function(_456){
var _457=undefined;
var code;
if(COMMONS.isString(_456)){
_457=_456.split(" ");
for(var i=0;i<_457.length;i++){
_457[i]=_457[i].split("-");
code=this.fKeys.get(_457[i][_457[i].length-1]);
if(code!==undefined){
_457[i][_457[i].length-1]=code;
}else{
_457[i][_457[i].length-1]=_457[i][_457[i].length-1].toUpperCase();
}
if(_457[i].length>1){
var _45a;
for(var j=0;j<_457[i].length-1;j++){
_457[i][j]=_457[i][j].toUpperCase();
}
}
}
}
return _457;
};
Updater.prototype.isMatchedKey=function(_45c,_45d){
var _45e=UpdaterDOMUtils.getEventKeyCode(_45d);
var _45f=false;
var _460;
for(var i=0;i<_45c.length;i++){
_460=_45c[i];
if(COMMONS.isNumber(_460[_460.length-1])){
_45f=_45e===parseInt(_460[_460.length-1]);
}else{
_45f=String.fromCharCode(_45e)===_460[_460.length-1];
}
if(_45f&&_460.length>1){
for(var j=0;j<_460.length-1;j++){
if((_460[j]==="SHIFT"&&!_45d.shiftKey)||(_460[j]==="CTRL"&&!_45d.ctrlKey)||(_460[j]==="ALT"&&!_45d.altKey)){
_45f=false;
break;
}
}
}
}
return _45f;
};
Updater.prototype.start=function(){
this.stop();
var _463=this;
this.fProcessID=window.setInterval(function(){
_463.update();
},this.fTimeout);
if(this.keyup===undefined){
this.keyup=function(_464){
if(_463.acceptKeyEvent(_464)){
_463.keyPressed(_464);
}
};
UpdaterDOMUtils.addEventListener(this.fContainer,"keyup",this.keyup);
}
if(this.mouseup===undefined){
this.mouseup=function(_465){
_463.mouseUp(_465);
};
UpdaterDOMUtils.addEventListener(this.fContainer,"mouseup",this.mouseup);
}
};
Updater.prototype.stop=function(){
if(this.fProcessID!==null){
window.clearInterval(this.fProcessID);
this.fProcessID=null;
}
};
Updater.prototype.destroy=function(){
this.stop();
if(this.mouseup!==undefined){
UpdaterDOMUtils.removeEventListener(this.fContainer,"mouseup",this.mouseup);
this.mouseup=undefined;
}
if(this.keyup!==undefined){
UpdaterDOMUtils.removeEventListener(this.fContainer,"mouseover",this.keyup);
this.keyup=undefined;
}
this.fActions=[];
};
Updater.prototype.createAction=function(aID,_467,_468,_469,_46a,_46b,_46c){
var _46d={id:aID,on:false,status:false,action:COMMONS.isFunction(_467)?_467:undefined,checker:COMMONS.isFunction(_468)?_468:undefined,elements:COMMONS.isArray(_469)?_469:(COMMONS.isString(_469)?[_469]:undefined),autoTimeout:isNaN(_46b)?0:_46b,key:COMMONS.isString(_46a)?this.parseHotKey(_46a):undefined,word:COMMONS.isString(_46c)?_46c.toUpperCase():undefined};
return _46d;
};
Updater.prototype.addAction=function(aID,_46f,_470,_471,_472,_473,_474){
var _475=this.createAction(aID,_46f,_470,_471,_472,_474,_473);
this.fCheckKey=_475!==undefined;
if(_475.word!==undefined){
this.fCheckWord=true;
this.fKeyBufferSize=Math.max(this.fKeyBufferSize,_475.word.length);
}
var _476=this.fActions.length;
for(var i=0;i<_476;i++){
if(this.fActions[i].id===_475.id){
_476=i;
break;
}
}
this.fActions[_476]=_475;
};
Updater.prototype.getAction=function(aID){
var _479=undefined;
for(var i=0;i<this.fActions.length;i++){
if(this.fActions[i].id===aID){
_479=this.fActions[i];
break;
}
}
return _479;
};
Updater.prototype.acceptKeyEvent=function(_47b){
var _47c=false;
var _47d=UpdaterDOMUtils.getEventTarget(_47b);
if(COMMONS.isObject(_47d)){
_47c=true;
if(_47d.nodeName==="TEXTAREA"||_47d.nodeName==="INPUT"||_47d.nodeName==="SELECT"||_47d.nodeName==="BUTTON"){
_47c=COMMONS.toBoolean(_47d.readOnly)||COMMONS.toBoolean(_47d.disabled);
}
}
return _47c;
};
Updater.prototype.switchAction=function(aID,anON){
for(var i=0;i<arguments.length-1;i++){
var _481=this.getAction(arguments[i]);
if(COMMONS.isObject(_481)){
_481.on=arguments[arguments.length-1];
}
}
};
Updater.prototype.acceptAction=function(_482){
var _483=COMMONS.isObject(_482)&&_482.on&&_482.status;
return _483;
};
Updater.prototype.keyPressed=function(_484){
var _485=null;
var _486;
if(this.fAutoRepeatTaskID!==null){
window.clearTimeout(this.fAutoRepeatTaskID);
this.fAutoRepeatTaskID=null;
}
if(!this.fLock&&(this.fCheckWord||this.fCheckKey)){
var _487=UpdaterDOMUtils.getEventKeyCode(_484);
if(this.fCheckWord){
if(this.fKeyBuffer.length>=this.fKeyBufferSize){
this.fKeyBuffer=this.fKeyBuffer.substring(1,this.fKeyBuffer.length);
}
this.fKeyBuffer+=String.fromCharCode(_487);
for(var i=0;i<this.fActions.length;i++){
_486=this.fActions[i];
if(!_486.on&&(this.fKeyBuffer===_486.word)){
_486.on=true;
}
}
}
if(this.fCheckKey){
for(var i=0;i<this.fActions.length;i++){
_486=this.fActions[i];
if(this.acceptAction(_486)&&_486.key!==undefined){
if(this.isMatchedKey(_486.key,_484)){
this.fLock=true;
try{
_485=_486.action.call(this,_484);
}
catch(ex){
this.fLogger.error("keyPressed, call of the action "+_486.id+" an error caused",ex);
}
var _489=this;
window.setTimeout(function(){
_489.fLock=false;
},10);
break;
}
}
}
}
}
return _485;
};
Updater.prototype.update=function(){
var _48a=function(_48b){
var _48c=true;
if(COMMONS.isFunction(_48b.checker)){
_48c=false;
try{
_48c=_48b.checker.call(this);
}
catch(ex){
this.fLogger.warning("update, call of action check method an error caused",ex);
}
}
return _48c;
};
if(!this.fLock){
var _48d;
var _48e;
var _48f;
for(var i=0;i<this.fActions.length;i++){
_48d=this.fActions[i];
if(_48d.on){
_48d.status=_48a.call(this,_48d);
if(COMMONS.isArray(_48d.elements)){
for(var j=0;j<_48d.elements.length;j++){
_48e=UpdaterDOMUtils.getElement(_48d.elements[j]);
_48f=this.getUIProcessor(_48e,_48d.status);
if(COMMONS.isFunction(_48f)){
_48f.call(this,_48e,_48d.status);
}
}
}
}
}
}
};
Updater.prototype.acceptUpdateUI=function(_492,_493){
return _492.status!==_493;
};
Updater.prototype.updateClassName=function(_494,_495){
var _496=false;
var _497=_494.className;
if(COMMONS.isString(_497)&&/Off\b|On\b/.test(_497)){
var _498=(_495)?_497.replace(/Off\b/,"On"):_497.replace(/On\b/,"Off");
if(_497!==_498){
_494.className=_498;
_496=true;
}
}
return _496;
};
Updater.prototype.updateImageUI=function(_499,_49a){
if(this.acceptUpdateUI(_499,_49a)){
if(!this.updateClassName(_499,_49a)){
var src=_499.src;
if(COMMONS.isString(src)&&/Off\b|On\b/.test(src)){
var _49c=(_49a)?src.replace(/Off\b/,"On"):src.replace(/On\b/,"Off");
if(src!==_49c){
_499.src=_49c;
}
}
}
_499.status=_49a;
}
};
Updater.prototype.updateControlUI=function(_49d,_49e){
if(this.acceptUpdateUI(_49d,_49e)){
if(!this.updateClassName(_49d,_49e)){
if(_49e){
_49d.disabled=undefined;
_49d.removeAttribute("disabled");
}else{
_49d.disabled=true;
}
}
_49d.status=_49e;
}
};
Updater.prototype.updateBlockUI=function(_49f,_4a0){
if(this.acceptUpdateUI(_49f,_4a0)){
if(!this.updateClassName(_49f,_4a0)){
var clip=_49f.clip;
if(COMMONS.isDefined(clip)){
clip=COMMONS.toInteger(clip)*2;
_49f.style.backgroundPosition=_4a0?("-"+clip+"px 0"):("0 0");
}
}
_49f.status=_4a0;
var _4a2;
var _4a3=_49f.childNodes;
for(var i=0;i<_49f.childNodes.length;i++){
_4a2=this.getUIProcessor(_4a3[i],_4a0);
if(COMMONS.isFunction(_4a2)){
_4a2.call(this,_4a3[i],_4a0);
}
}
}
};
Updater.prototype.mouseUp=function(_4a5){
if(this.fAutoRepeatTaskID!==null){
window.clearTimeout(this.fAutoRepeatTaskID);
this.fAutoRepeatTaskID=null;
}
};
Updater.prototype.call=function(aID){
var _4a7=function(_4a8){
var _4a9=this;
if(this.fAutoRepeatTaskID!==null){
window.clearTimeout(this.fAutoRepeatTaskID);
this.fAutoRepeatTaskID=null;
}
if(this.fLock){
this.fAutoRepeatTaskID=window.setTimeout(function(){
_4a7.call(_4a9,_4a8);
},_4a8.autoTimeout);
}else{
if(this.acceptAction(_4a8)){
this.fLock=true;
try{
_4a8.call(this);
if(this.acceptAction(_4a8)){
this.fAutoRepeatTaskID=window.setTimeout(function(){
_4a7.call(_4a9,_4a8);
},_4a8.autoTimeout);
}
}
catch(ex){
this.fLogger.error("doInvoke, action "+this.fAction.id+" invocation error caused",ex);
}
this.fLock=false;
}
}
};
if(this.fAutoRepeatTaskID!==null){
window.clearTimeout(this.fAutoRepeatTaskID);
this.fAutoRepeatTaskID=null;
}
if(!this.fLock){
var _4aa=this.getAction(aID);
if(this.acceptAction(_4aa)){
this.fLock=true;
var _4ab=this;
try{
_4aa.action.call(this);
if(_4aa.autoTimeout>1&&this.acceptAction(_4aa)){
this.fAutoRepeatTaskID=window.setTimeout(function(){
_4a7.call(_4ab,_4aa);
},_4aa.autoTimeout);
}
}
catch(ex){
this.fLogger.error("invoke, action "+_4aa.id+"invocation error caused",ex);
}
this.fLock=false;
}
}
};
